﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLPMT_BUS;
using QLPMT_DTO;

namespace my_project_qlpmt1
{
    public partial class FR_TraCuuBenhNhan : Form
    {
        public FR_TraCuuBenhNhan()
        {
            InitializeComponent();
        }
        public void ThongTinDuLieu()
        {

            List<LoaiBenh> list = new List<LoaiBenh>();
            list = new LoaiBenhBUS().GetAll();
            LoaiBenh dto = new LoaiBenh();
            dto.Tenloaibenh = "Danh sách bệnh";
            dto.Maloaibenh = "0";
            list.Insert(0, dto);
            cbb_loaibenh.DataSource = list;
            cbb_loaibenh.DisplayMember = "Tenloaibenh";
            cbb_loaibenh.ValueMember = "Maloaibenh";

        }
        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void btn_timkiem_Click(object sender, EventArgs e)
        {
            string ma = cbb_loaibenh.SelectedValue.ToString();
            if (ma == "0")
                ma = "";
            string ten = txt_hoten.Text;
            string diachi = txt_diachi.Text;
            string namsinh = txt_NamSinh.Text;
            string trieuchung = txt_trieuchung.Text;
            DateTime ngaybd = dti_ngaybd.Value;
            DateTime ngaykt = dti_ngaykt.Value;
            List<BenhNhan> list = new BenhNhanBUS().Search(ten, diachi, namsinh, ma, trieuchung, ngaybd, ngaykt);
            dgv_danhsachtimkiem.DataSource = list;
            dgv_danhsachtimkiem.Columns["Mabenhnhan"].Visible = false;
            dgv_danhsachtimkiem.Columns["Tengioitinh"].Visible = false;
            dgv_danhsachtimkiem.Columns["Namsinh"].Visible = false;
            dgv_danhsachtimkiem.Columns["GioiTinh"].Visible = false;
            danhsothutuchodatagridview(dgv_danhsachtimkiem, "STT");
        }
        public void danhsothutuchodatagridview(DataGridView table, string colunmName)
        {
            int i = 0;
            while (i < table.RowCount)
            {
                table.Rows[i].Cells[colunmName].Value = i + 1;
                i++;
            }
        }
        private void FR_TraCuuBenhNhan_Load(object sender, EventArgs e)
        {
            ThongTinDuLieu();
        }
    }
}
